#include "algorithm.h"

float StageBody::ObtainDeltaV(){

    float DeltaV = 0.0f;


}

float ShipBody::NormalizeAngle(float Angle)
{
    if ( Angle > 180.0f ){
        while( Angle > 180.0f )
        {
            Angle -= 360.0f;
        }
    }
    else if ( Angle < -180.0f ){
        while( Angle > 180.0f )
        {
            Angle += 360.0f;
        }
    }

    return Angle;
}

ShipBody::ShipBody(){

    if( this->Latitude >= 0.0f || this->Latitude <= 90.0f ){
        float CentrifugalForce = 0;
        float InitialV = 0;

        float HuangdaomianAcc = EQUATER_ACCL * cosf( (2 * PI * this->Latitude) / 360.0f );
        CentrifugalForce = HuangdaomianAcc * sinf( (2 * PI * this->Latitude) / 360.0f );

        this->EarthGravity = EARTH_GRAVITY - CentrifugalForce;

        this->OrbitAngle = ShipBody::NormalizeAngle(this->OrbitAngle);

        InitialV = EQUATER_V * cosf( (2 * PI * this->Latitude) / 360.0f ) * cosf( (2 * PI * this->OrbitAngle) / 360.0f );
    }
    else{

    }

}
